package com.softserveinc;

import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MovieManagerPreferenceActivity extends PreferenceActivity {

	private OnClickListener confirmListener = new OnClickListener() {

		@Override
		public void onClick(final View v) {
			setResult(MovieManagerActivity.PREFERENCE_RESULT_CONFIRM);
			finish();
		}
	};
	private OnClickListener cancelListener = new OnClickListener() {

		@Override
		public void onClick(final View v) {
			finish();
		}
	};

	@Override
	protected void onCreate(final Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		setContentView(R.layout.widget_config);
		addPreferencesFromResource(R.xml.movie_preference);

		setResult(MovieManagerActivity.PREFERENCE_RESULT_CANCEL);

		initButtons();
	}

	private void initButtons() {
		Button confirm = (Button) findViewById(R.id.button_confirm_widget);
		confirm.setOnClickListener(confirmListener);

		Button cancel = (Button) findViewById(R.id.button_cancel_widget);
		cancel.setOnClickListener(cancelListener);
	}
}
